package com.iot08.api.controller;

import com.iot08.api.service.DeviceService;
import com.iot08.api.service.supplement.HealthService;
import com.iot08.api.vo.request.AddHealthfunctionReqVO;
import com.iot08.api.vo.request.GetHealthfunctionReqVO;
import com.iot08.common.utils.response.ResponseMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author weichao 1299101858@qq.com
 * @version 1.0
 * @date 4/14/22 3:39 PM
 */
@Slf4j
@RestController
@RequestMapping("getway/")
public class HealthDataController {
    @Resource
    private DeviceService deviceService;

    @Resource
    private HealthService healthService;
    /**
     * 健康功能(心率/血压/血氧) 获取数据
     * @param imei
     * @param vo
     * @time: 4/14/22 1:56 PM
     * @author: Weichao
     * @version 1.0
     */
    @GetMapping("/heart_temperature/{imei}")
    public ResponseMap getHeart_temperature(@PathVariable("imei") String imei,
                                            @Validated GetHealthfunctionReqVO vo, BindingResult bindingResult) {
        return healthService.getHealthfunction(imei, vo);
    }

    /**
     * 设置频率(包括立即测量)
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2020/12/7 9:45
     * @author: Rock
     * @version 1.0
     */
    @PostMapping("/heart_temperature/{imei}")
    public ResponseMap setHeart_temperature(@PathVariable("imei") String imei,
                                            @Validated AddHealthfunctionReqVO vo, BindingResult bindingResult) {
        return healthService.setHealthfunction(imei, vo);
    }
}
